<?php

//Copiar todo este conteudo sem alterar, usar Copy e Paste
//////////////////////////////////////////////////////////////////////////////
//                                                                          //
//                                                                          //
//Quebrar a Rotina lda. NIF 507969499                                       //
//www.pagamentoseguros.com, geral@pagamentoseguros.com                      //
//                                                                          //
//Parte deste cdigo  opensource Joomla e Virtuemart.                      //
//Restante cdigo tem direitos reservados embora seja de utilizao livre.  //
//Est proibida a sua adulterao.                                          //
//Ningum pode obter lucros reivindicando a autoria deste cdigo.           //
//////////////////////////////////////////////////////////////////////////////
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
global $mosConfig_live_site, $mosConfig_absolute_path, $sess, $ps_vendor_id,
	$VM_LANG, $mosConfig_smtpauth, $mosConfig_mailer, $vmLogger,
	$mosConfig_smtpuser, $mosConfig_smtppass, $mosConfig_smtphost, $mosConfig_mailfrom, $mosConfig_fromname, $ps_product, $CURRENCY_DISPLAY, $mosConfig_lang, $database;



include($mosConfig_absolute_path.'/multibanco/multibanco.cfg.php');

//echo $mosConfig_absolute_path;

$order_id = $db->f("order_id");
$order_value = $db->f("order_total");

      
$ent_id = $entidade;
$subent_id = $subentidade;



echo "<br>";
echo '<img src= "http://www.pagamentoseguros.com/multibanco/multibanco.jpg" height="97" width="108" align="left" alt="Success" border="0" style="float: left;" /><br>';

echo '<div style="TEXT-ALIGN: justify"> <strong> O pagamento por multibanco  feito em qualquer caixa multibanco.<br><br>Tambm pode pagar pelo seu homebanking na opo de pagamento de servios.<br><br><br><br><br></strong></div>';



echo '<div style="TEXT-ALIGN: center"> <strong>A expedio ser efectuada aps o pagamento.<br></strong></div>';
echo '<div style="TEXT-ALIGN: center"> <strong><br>Imprima esta pgina ou tome nota dos dados abaixo.<br></strong></div>';
echo '<div style="TEXT-ALIGN: center"> <strong><br>Encomenda N '.$order_id.'<br><br></strong></div>';


$file='http://www.pagamentoseguros.com/multibanco/getref.php';
$file.='?entidade='.$ent_id;
$file.='&subentidade='.$subent_id;
$file.='&valor='.$order_value;
$file.='&encomenda='.$order_id;

//echo $file."<br>";

$lines = file($file);

//echo "lines 0 deu ".$lines[0]."<br>";

$len=strlen($lines[0]);

$entidade = substr($lines[0], 0, 5);
//echo "entidade ".$entidade."<br>";

$ref = substr($lines[0], 6, 9);
//echo "referencia ".$ref."<br>";

$valor = round(substr($lines[0], 16, $len-16),2);
//echo "valor ".$valor."<br>";


       echo '<div style="TEXT-ALIGN: center"><img src="http://www.pagamentoseguros.com/multibanco/multibanco.jpg" height="69" width="77" align="center" alt="Success" border="0" style="IMAGE-ALIGN: center" /><br>';
   echo '</div>';   
       
       echo '<br><div style="TEXT-ALIGN: center"><strong>   Entidade:    </strong>'.$ent_id;
       echo '</div>';
       echo '<div style="TEXT-ALIGN: center"><strong>   Referncia: </strong>'.$subent_id." ".substr($ref, 3, 3)." ".substr($ref, 6, 3);
       echo '</div>';
       echo '<div style="TEXT-ALIGN: center"><strong>   Valor: </strong>'.str_replace(".", ",", $valor);
       echo ' Euro';
       echo '</div>';
 
      


	
		 	
	// modif
	if(is_null($sess)){
		$Itemid = 1;
	} else {
		$Itemid = $sess->getShopItemid();
	}
	$url = $mosConfig_live_site."/index.php?option=com_virtuemart&page=account.order_details&order_id=".$order_id."&Itemid=$Itemid";
		
	


?>
